/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.gastronomico.demo.web;

import com.gastronomico.demo.domain.Usuario;
import com.gastronomico.demo.service.UsuarioService;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 *
 * @author mmuguerza
 */

@Controller
public class UsuarioController {

    @Autowired
    UsuarioService service;

    @RequestMapping(value = "/usuarioLista.htm", method = RequestMethod.GET)
    public ModelAndView usuario(HttpServletRequest req){
        ModelAndView mav = new ModelAndView("usuarioLista");
        List<Usuario> usuarioLista = service.obtenerUsuarios();
        System.out.println("Usuarios:" + usuarioLista.size());
        mav.addObject("usuarioLista", usuarioLista);
        return mav;
    }
}
